package com.obrempon.credit.market.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.obrempon.credit.market.R
import com.obrempon.credit.market.utils.ObremponImageUtil
import com.obrempon.module.adapter.ObremponRecyclerViewAdapter
import com.obrempon.module.adapter.ObremponViewHolderHelper
import org.json.JSONObject

/**
 * ObremponCredit
 * @Author wwdeng
 * @CreateTime: 2024/11/27 13:45
 * @Annotation：意见反馈 - 图片列表
 */
class ObremponUserFeedbackImageApt(recyclerView: RecyclerView?): ObremponRecyclerViewAdapter<JSONObject>(recyclerView) {

    override fun getItemViewType(position: Int): Int {
        val model = getItem(position)
        if (model.optBoolean("isDefault",true)){
            return R.layout.obrempon_user_feedback_image_add_item
        }
        return R.layout.obrempon_user_feedback_image_item
    }
    override fun setItemChildListener(helper: ObremponViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.pictureRemove) //删除
        helper.setItemChildClickListener(R.id.pictureAddLayout)//添加
    }

    override fun fillData(helper: ObremponViewHolderHelper, position: Int, model: JSONObject) {
        //是否是默认图片
        if (!model.optBoolean("isDefault",true)){
            val feedbackPicture = helper.getImageView(R.id.feedbackPicture)
            ObremponImageUtil.instance.loadImageUrl(mContext,feedbackPicture,model.optString("imgPath"))
        }
    }
}